 <?php 


$username = $_POST['username'];
$password = $_POST['password'];

//$username = "trang";
//$password = "trangsf";
include("opendb.php");
include("functions.php");
$res = isValidUser($username,$password);
if($res!=1) {
echo "0";
exit;
}

$listingid = $_POST['listingid'];
$event_id = $_POST['event_id'];
//$listingid = 282815;

$query = "select * from Users where Username='".$username."'";
$result = mysql_query($query) or die ("SQL Error".mysql_error());
$row=mysql_fetch_assoc($result);
$userid = $row['ID'];



		$lquery = "select * from PROPERTIES p inner join Prop_Owner_Con c on p.OID = c.Prop_OID where p.OID='".$listingid."' and c.Owner = '".$userid."'";
		$lresult = mysql_query($lquery) or die ("SQL Error".mysql_error());
		$listing_row=mysql_fetch_assoc($lresult);
		if (mysql_num_rows($lresult) === 0)
		{
			echo "101";
			exit;
		}
		
		$sql = "update Events set Title = '".$_POST['title']."', Event_Type = '".$_POST['type']."', Time_To = '".$_POST['to']."',Time_From = '".$_POST['from']."',Time_Fix = '".$_POST['fix']."',Notes = '".$_POST['notes']."',Event_Date = '".$_POST['date']."' where ID = '".$event_id."'";
	$result = mysql_query($sql) or die ("SQL Error".mysql_error());
	//echo $sql;
echo "1";

?>